package com.example.administrator.szb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.administrator.szb.R;
import com.example.administrator.szb.bean.AnliBean;
import com.example.administrator.szb.http.URLAddress;

import java.util.List;

/**
 * Created by stone on 2018/1/19.
 */

public class Anliadapter extends BaseAdapter {
    private Context context;
    private List list;
    LayoutInflater inflater;
    public Anliadapter(Context context, List list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public  Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView==null){
            convertView = inflater.inflate(R.layout.item_shocang_zx,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        AnliBean anliBean = (AnliBean) getItem(position);
        holder.title.setText(anliBean.getTitle());
        holder.time.setText(anliBean.getCreate_time());
        Glide.with(context).load(URLAddress.HOST_PORT+anliBean.getImg()).placeholder(R.mipmap.defaultimg).into(holder.head_img);
        return convertView;
    }

    class ViewHolder{
         LinearLayout checkBox_ll;
         TextView title;
         TextView time;
         TextView liulan;
         ImageView head_img;
         View lines;
         View lines2;
        public ViewHolder(View view){
            checkBox_ll = (LinearLayout) view.findViewById(R.id.checkBox_ll);
            title = (TextView) view.findViewById(R.id.title);
            time = (TextView) view.findViewById(R.id.time);
            liulan = (TextView) view.findViewById(R.id.liulan);
            head_img = (ImageView) view.findViewById(R.id.head_img);
            lines = (View) view.findViewById(R.id.lines);
            lines2 = (View) view.findViewById(R.id.lines2);
            liulan.setVisibility(View.GONE);
            lines2.setVisibility(View.VISIBLE);
        }
    }
}
